def activity_selection(activities):
    # 按照结束时间排序
    activities.sort(key=lambda x: x[1])

    # 活动列表
    selected = []

    # 选择第一个活动
    if activities:
        selected.append(activities[0])

    # 最后一个被选中的活动索引
    last_selected = 0

    # 贪心选择剩余活动
    for i in range(1, len(activities)):
        # 如果当前活动的开始时间大于等于上一个选择的活动的结束时间
        if activities[i][0] >= activities[last_selected][1]:
            selected.append(activities[i])
            last_selected = i

    return selected



activities = [
    (1, 4), (3, 5), (0, 6), (5, 7), (3, 9),
    (5, 9), (6, 10), (8, 11), (8, 12), (11, 14)
]

selected_activities = activity_selection(activities)
print("选择的活动数量:", len(selected_activities))
print("选择的活动:", selected_activities)